
<div class="common-tit">
  <h2>编辑学员</h2>
  <span>学员系统 > 学员详情 > 编辑学员</span>
</div>
<div class="cur-box">
  <h3>
    <span>基本信息</span>
  </h3>
  <div class="cur-basic clearfix">
    <div class="ads-info clearfix">
      <div class="camera">
        <div class="upl">本地上传</div>
      </div>
      <ul class="bs-box">
        <li>
          <input type="text" class="in-l required" placeholder="姓名">
          <input type="text" class="in-r" placeholder="别名 / 英文名">
        </li>
        <li>
          <div class="list-box b-sex" choice="mandatory">
            <div class="downbtn">
              <span>请选择性别</span>
              <em></em>
            </div>
            <ul class="dropdown-menu">
              <li class="cho-tit">请选择性别</li>
              <li>男</li>
              <li>女</li>
            </ul>
          </div>
          <b>请选择</b>
          <div class="list-box group" choice="mandatory">
            <div class="downbtn">
              <span>信息来源</span>
              <em></em>
            </div>
            <ul class="dropdown-menu">
              <li class="cho-tit">信息来源</li>
              <li>信息来源1</li>
              <li>信息来源2</li>
              <li>信息来源3</li>
            </ul>
          </div>
        </li>
        <li>
          <input id="stuTel" type="text" class="in-l" placeholder="手机号">
          <input type="text" class="in-r" placeholder="微信号">
        </li>
        <li>
          <div class="date-ibox dr">
            <input type="text" class="in-r date-input" readOnly="true" placeholder="出生年月">
          </div>
          <input type="text" class="in-r" placeholder="紧急联系人姓名">
        </li>
        </li>
        <li>
          <input type="text" class="in-l" placeholder="紧急联系人电话">
        </li>
        <li>
          <input type="text" class="in-a" placeholder="联系地址">
        </li>
        <li>
          <input type="text" class="in-a" placeholder="备注信息">
        </li>
      </ul>	
    </div>
  </div>
  <div class="intention-btn">保存</div>
</div>
<script src="/assets/js/common.js"></script>
<script>
$(function(){
  $('.date-list1').date_input();
  $(".date-list2").date_input();
  $(".date-input").date_input();
});
$('.date-list2').on("click", function() {
  updateT1();
  $('.nav span').on("click", function() {
    if ($(this).parent().parent().parent().prev().attr("class") == "date-list2") {
      updateT1();
    };
  });
});
$('.date-list1').on("click", function() {
  updateT2();
  $('.nav span').on("click", function() {
    if ($(this).parent().parent().parent().prev().attr("class") == "date-list1") {
      updateT2();
    };
  });
});
$(".intention-btn").on("click", function() {
  if(adstuSet()) {
    console.log("okokokokok");
    var postJson = {
      "potential_student" : [{
        "name" : $(".bs-box input").eq(0).val(),
        "alias_name" : $(".bs-box input").eq(1).val(),
        "sex" : $(".b-sex").find("span").text(),
        "source_from" : $(".bs-box .group").find("span").text(),
        "weixin" : $(".bs-box input").eq(3).val(),
        "birthday" : $(".bs-box input").eq(4).val(),
        "emergency_contact" : $(".bs-box input").eq(5).val(),
        "emergency_mobile" : $(".bs-box input").eq(6).val(),
        "address" : $(".bs-box input").eq(7).val(),
        "备注信息" : $(".bs-box input").eq(8).val()
      }]
    };
    console.log(postJson);
  }
})
// 验证是否必填
function adstuSet() {
  var writeIn = true;
  for (var i = 0; i < $(".bs-box .required").length; i++) {
    if ($($(".required")[i]).val() == "") {
      $($(".required")[i]).css({
        "border" : "1px solid #ff5a60" 
      });
      writeIn = false;
    } else {
      $($(".required")[i]).css({
        "border" : "1px solid #9ea0b7" 
      });
    }
  }
  if ($(".b-sex").attr("choice") == "mandatory") {
    $(".b-sex").next("b").css({
      "display" : "inline"
    });
    writeIn = false;
  }
  // 添加 ajax 如果
  return writeIn;
}
</script>
